/**************************************************************************
*                                                                         *
*         Java Grande Forum Benchmark Suite - Thread Version 1.0          *
*                                                                         *
*                            produced by                                  *
*                                                                         *
*                  Java Grande Benchmarking Project                       *
*                                                                         *
*                                at                                       *
*                                                                         *
*                Edinburgh Parallel Computing Centre                      *
*                                                                         * 
*                email: epcc-javagrande@epcc.ed.ac.uk                     *
*                                                                         *
*                                                                         *
*      This version copyright (c) The University of Edinburgh, 2001.      *
*                         All rights reserved.                            *
*                                                                         *
**************************************************************************/


package section2.series;
import jgfutil.*; 

public class JGFSeriesBench extends SeriesTest implements JGFSection2{ 

  public static int nthreads;
  private int size; 

  public JGFSeriesBench(int nthreads) {
	this.nthreads=nthreads;
  }

  public void JGFsetsize(int size){
    this.size = size;
  }

  public void JGFinitialise(){
    array_rows = size;
    buildTestData();
  }
 
  public void JGFkernel(){
    Do(); 
  }

  public void JGFvalidate(){/*
    for (int i = 0; i < 8; i++)
      for (int j = 0; j < 2; j++)
	System.out.println(TestArray[j][i]);*/
	
  }

  public float[][] getResult(int size)
  {

    JGFInstrumentor.addTimer("Section2:Series:Kernel", "coefficients",size);
    JGFsetsize(size);
    JGFinitialise();
    JGFkernel();
    float[][] res = TestArray;
    JGFtidyup();
    JGFInstrumentor.addOpsToTimer("Section2:Series:Kernel", (float) (array_rows * 2 - 1));
    return res;
  }

  public void JGFtidyup(){
    freeTestData(); 
  }  



  public void JGFrun(int size){


    JGFInstrumentor.addTimer("Section2:Series:Kernel", "coefficients",size);
    JGFsetsize(size); 
    JGFinitialise(); 
    JGFkernel(); 
    JGFvalidate(); 
    JGFtidyup(); 

     
    JGFInstrumentor.addOpsToTimer("Section2:Series:Kernel", (float) (array_rows * 2 - 1));
    double time = JGFInstrumentor.readTimer("Section2:Series:Kernel");
    System.out.print(time+" ");
  }
}
